package exception;

public interface ExceptionEnum {
    String getCode();

    String getMessage();

    /**
     * 根据 code 获取枚举
     */
    static <T extends Enum<?> & ExceptionEnum> T getByCode(Class<T> enumClass, String code) {
        for (T each : enumClass.getEnumConstants()) {
            if (each.getCode().equals(code)) {
                return each;
            }
        }
        return null;
    }
}